package com.kexio.enterprise.observability.health.result;

import com.kexio.enterprise.observability.health.enums.HealthStatus;

import java.time.LocalDateTime;
import java.util.Map;

/**
 * 健康检查结果
 * 
 * @author Kexio
 * @since 1.0.0
 */
public class HealthCheckResult {
    private String componentName;
    private HealthStatus status;
    private String message;
    private Map<String, Object> details;
    private LocalDateTime checkTime;
    private long responseTime;
    private Throwable exception;

    public HealthCheckResult() {}

    public HealthCheckResult(String componentName, HealthStatus status) {
        this.componentName = componentName;
        this.status = status;
        this.checkTime = LocalDateTime.now();
    }

    public HealthCheckResult(String componentName, HealthStatus status, String message) {
        this(componentName, status);
        this.message = message;
    }

    // Getters and Setters
    public String getComponentName() { return componentName; }
    public void setComponentName(String componentName) { this.componentName = componentName; }
    
    public HealthStatus getStatus() { return status; }
    public void setStatus(HealthStatus status) { this.status = status; }
    
    public String getMessage() { return message; }
    public void setMessage(String message) { this.message = message; }
    
    public Map<String, Object> getDetails() { return details; }
    public void setDetails(Map<String, Object> details) { this.details = details; }
    
    public LocalDateTime getCheckTime() { return checkTime; }
    public void setCheckTime(LocalDateTime checkTime) { this.checkTime = checkTime; }
    
    public long getResponseTime() { return responseTime; }
    public void setResponseTime(long responseTime) { this.responseTime = responseTime; }
    
    public Throwable getException() { return exception; }
    public void setException(Throwable exception) { this.exception = exception; }

    public boolean isHealthy() {
        return status == HealthStatus.UP;
    }
}
